package jm.data.structure.queue;

import jm.data.structure.utils.PrintUtils;

/**
 * @Description 双端队列测试
 * @date 2022/4/8 14:45
 */
public class MainCircleDeque {
    public static void main(String[] args) {
        CircleDeque<Integer> deque = new CircleDeque<>();
        // 尾  3 2 1头
        deque.enQueueFront(3);
        deque.enQueueFront(2);
        deque.enQueueFront(1);

        // 尾 7 8 9  3 2 1头
        deque.enQueueRear(9);
        deque.enQueueRear(8);
        deque.enQueueRear(7);

        while (!deque.isEmpty()){
            System.out.println(deque.deQueueFront());
        }

        // 尾  3 2 1头
        deque.enQueueFront(3);
        deque.enQueueFront(2);
        deque.enQueueFront(1);

        // 尾 7 8 9  3 2 1头
        deque.enQueueRear(9);
        deque.enQueueRear(8);
        deque.enQueueRear(7);

        System.out.println(PrintUtils.partPrint("测试deRear"));
        while (!deque.isEmpty()){
            System.out.println(deque.deQueueRear());
        }

        for (int i = 0; i < 20; i++) {
            deque.enQueueRear(i);
        }
        System.out.println(PrintUtils.partPrint("测试扩容"));
        //尾 19...6543210 头
        while (!deque.isEmpty()){
            System.out.println(deque.deQueueRear());
        }
    }
}
